package com.reform.controller.phase;


import com.reform.res.Result;
import com.reform.service.IViewBatchPhaseService;
import com.reform.service.IViewSelectBatchPhaseService;
import com.reform.service.IViewUnselectBatchPhaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;

/**
 * <p>
 * VIEW 前端控制器
 * </p>
 *
 * @author mortale
 * @since 2021-09-12
 */
@Api(tags = "ViewBatchPhaseController")
@RestController
@RequestMapping("/view-batch-phase")
public class ViewBatchPhaseController {

    @Autowired
    IViewBatchPhaseService viewBatchPhaseService;
    @Autowired
    IViewUnselectBatchPhaseService viewUnselectBatchPhaseService;
    @Autowired
    IViewSelectBatchPhaseService viewSelectBatchPhaseService;

    @ApiOperation(value = "获取所有阶段检查信息")
    @GetMapping("/getAllBatchPhase")
    public Result getAllBatchPhase() throws SQLException {
        return viewBatchPhaseService.getAllBatchPhase();
    }

    @ApiOperation(value = "通过phaseId获取所有阶段检查信息")
    @PostMapping("/getBatchPhaseByPhaseId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phaseId", value = "阶段检查编号", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result getBatchPhaseByPhaseId(String phaseId) throws SQLException {
        return viewBatchPhaseService.getBatchPhaseByPhaseId(phaseId);
    }

    @ApiOperation(value = "通过batchId获取所有阶段检查信息")
    @PostMapping("/getBatchPhaseByBatchId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "batchId", value = "批次编号", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result getBatchPhaseByBatchId(String batchId) throws SQLException {
        return viewBatchPhaseService.getBatchPhaseByBatchId(batchId);
    }

    @ApiOperation(value = "通过phaseId获取已选阶段检查信息")
    @PostMapping("/getSelectByPhaseId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phaseId", value = "阶段检查编号", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result getSelectByPhaseId(String phaseId) throws SQLException {
        return viewSelectBatchPhaseService.getSelectByPhaseId(phaseId);
    }

    @ApiOperation(value = "获取未选阶段检查信息")
    @PostMapping("/getNotSelectPhaseByPhaseId")
    public Result getNotSelectPhaseByPhaseId() throws SQLException {
        return viewUnselectBatchPhaseService.getNotSelectPhaseByPhaseId();
    }

    @ApiOperation(value = "通过阶段检查编号获取批次名称")
    @PostMapping("/getBatchNameByPhaseId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phaseId", value = "阶段检查编号", paramType = "query", dataTypeClass = String.class, required = true),
    })
    public Result getBatchNameByPhaseId(String phaseId) throws SQLException {
        return viewBatchPhaseService.getBatchNameByPhaseId(phaseId);
    }

}
